<script setup lang="ts">
import {PAY_TYPE} from "~/const/Maps";
const time=ref([]);
definePageMeta({
  layout:'admin',
  title:'充值列表',
});
const form=reactive({
  limit:20,
  page:1,
  order_sn:'',
  pay_type:'',
  start_time:'',
  end_time:'',
});
watchEffect(()=>{
  form.start_time=time.value?.[0]??''
  form.end_time=time.value?.[1]??''
})
const {data:list,refresh}=await useServerGet('/recharge/getOrderList',form)
const search=()=>{
  refresh&&refresh();
}
</script>

<template>
<div>
  <el-card>
    <div class="flex">
      <div class="w-52 mr-2">
        <el-input placeholder="订单搜索" v-model="form.order_sn" class="w-40" clearable></el-input>
      </div>
      <div class="w-52">
        <el-select v-model="form.pay_type" placeholder="充值方式" clearable>
          <el-option :label="label" :value="value" v-for="(label,value) in PAY_TYPE"></el-option>
        </el-select>
      </div>
      <div class="w-96 mx-2">
        <el-date-picker type="daterange" placeholder="充值时间" v-model="time" value-format="YYYY-MM-DD" clearable></el-date-picker>
      </div>
      <div class="w-20">
        <el-button type="primary" @click="search">搜索</el-button>
      </div>
    </div>
  </el-card>
  <el-card class="mt-4">
    <el-table
        ref="multipleTable1"
        :data="list.data.list"
        tooltip-effect="dark"
        style="width: 100%"
        align="center"
        >
      <el-table-column label="订单ID">
        <template #default="scope">{{ scope.row.order_sn }}</template>
      </el-table-column>
      <el-table-column label="支付类型">
        <template #default="scope">{{ PAY_TYPE[scope.row.pay_type] }}</template>
      </el-table-column>
      <el-table-column label="支付金额">
        <template #default="scope"><span class="text-[var(--el-color-primary)]">{{ scope.row.amount }}</span>元</template>
      </el-table-column>
      <el-table-column
          prop="created_at"
          label="创建时间"
      >
      </el-table-column>
      <el-table-column
          prop="updated_at"
          label="更新时间"
         >
      </el-table-column>
    </el-table>
    <MyPage v-model:page="form.page" v-model:perpage="form.limit" v-model:total="list.data.total" @change="refresh"></MyPage>
  </el-card>
</div>
</template>

<style scoped lang="scss">

</style>